#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
int T,n,m,L,V,d[N],v[N],a[N],p[N];
double v1[N];
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>T;
	for(int k=1;k<=T;k++)
	{
		int ans=0,ymy=0;
		cin>>n>>m>>L>>V;
		for(int i=1;i<=n;i++)
			cin>>d[i]>>v[i]>>a[i];
		for(int i=1;i<=m;i++)
			cin>>p[i];
		sort(p+1,p+1+m);
		for(int i=1;i<=n;i++)
		{
			if(d[i]<=p[m])
			{
				d[i]=p[m]-d[i];
				v1[i]=sqrt(v[i]*v[i]+2*a[i]*d[i]);
				if(v1[i]>V) {ymy=1;ans++;}
			}
		}
		cout<<ans<<" "<<m-ymy<<endl;
	}
}
